package com.example.windowdemo.window.flyweight;

import com.example.windowdemo.window.Window;

import java.util.HashMap;
import java.util.Map;

/**
 * @author: njb
 * @date: 2023/8/3 15:25
 * @desc:
 */
public class FlyweightWindowFactory {
    private final Map<String, FlyweightWindow> windows = new HashMap<>();

    public FlyweightWindow getWindow(String tag) {
        FlyweightWindow window = windows.get(tag);
        if (window == null) {
            window = new FlyweightWindow();
            windows.put(tag, window);
        }
        return window;
    }
}
